import { createVuetify, type VuetifyOptions } from "vuetify";
import DayJsAdapter from '@date-io/dayjs'
import * as components from "vuetify/components";
import * as directives from "vuetify/directives";
import { aliases, mdi } from "vuetify/iconsets/mdi-svg"; // 使用 Material Design 图标
import { enUS, zhCN } from "date-fns/locale";

// 自定义主题配置
const customTheme: VuetifyOptions["theme"] = {
  defaultTheme: "light",
  themes: {
    light: {
      dark: false,
      colors: {
        primary: "#1976D2",
        secondary: "#424242",
        error: "#FF5252",
        info: "#2196F3",
        success: "#4CAF50",
        warning: "#FB8C00",
      },
    },
    dark: {
      dark: true,
      colors: {
        primary: "#2196F3",
        secondary: "#424242",
        // ...其他颜色
      },
    },
  },
};

// 全局组件默认配置
const defaults: VuetifyOptions["defaults"] = {
  VBtn: {
    variant: "flat",
    rounded: "md",
  },
  VTextField: {
    variant: "outlined",
    density: "comfortable",
    hideDetails: "auto",
  },
  VSelect: {
    variant: "outlined",
  },
  VDataTable: {
    fixedHeader: true,
    hover: true,
  },
};

// 主配置
export default createVuetify({
  components,
  directives,
  theme: customTheme,
  defaults,
  date: {
    adapter: DayJsAdapter, // 使用 date-fns 适配器
    locale: { en: enUS, zh: zhCN }, // 设置语言
  },
  icons: {
    defaultSet: "mdi",
    aliases,
    sets: { mdi },
  },
  // 其他可选配置
  blueprint: {
    defaults: {
      VBtn: { color: "primary" },
    },
  },
} as VuetifyOptions); // 类型断言确保配置正确
